package com.idanchuang.component.core.util;

/**
 * <p>
 * 字符串工具
 * </p>
 *
 * @author jiang
 * @date 2019-11-09 14:13
 */
public class StringUtil {

    /**
     * 判断某字符串是否为空
     */
    public static boolean isEmpty(CharSequence cs) {
        return cs == null || cs.length() == 0;
    }

    /**
     * 判断某字符串是否非空
     */
    public static boolean isNotEmpty(CharSequence cs) {
        return !isEmpty(cs);
    }

    /**
     * 判断某字符串是否为空或长度为0或由空白符构成
     */
    public static boolean isBlank(CharSequence cs) {
        int strLen;
        if (cs != null && (strLen = cs.length()) != 0) {
            for (int i = 0; i < strLen; ++i) {
                if (!Character.isWhitespace(cs.charAt(i))) {
                    return false;
                }
            }
            return true;
        } else {
            return true;
        }
    }

    /**
     * 判断某字符串是否不为空且长度不为0且不由空白符(whitespace) 构成
     */
    public static boolean isNotBlank(CharSequence cs) {
        return !isBlank(cs);
    }

}
